<%@page import="java.util.Set"%>
<%@page import="java.util.TreeMap"%>
<%@page contentType="application/json; charset=UTF-8"%>
<%!private static class DataCollector {
	private static TreeMap<Integer, TreeMap<String, String>> mapData = null;
	private static TreeMap<Integer, TreeMap<String, TreeMap<String, String>>> countrySubregionData = null;

	public static String getData(Object country_id, Object region_name) {
	    checkDataExists();
	    Integer iCountry_id = null;
	    try {
		iCountry_id = Integer.parseInt(country_id.toString());
	    } catch (Exception ex) {
		return "[]";
	    }
	    TreeMap<String, String> data = null;
	    if (region_name == null)
		data = mapData.get(iCountry_id);
	    else {
		data = getSubregions(iCountry_id, region_name.toString());
	    }
	    if (data == null || data.isEmpty())
		return "[]";
	    String result = "[";

	    Set<String> keys = data.keySet();
	    String mData = "";
	    for (String key : keys) {
		String value = data.get(key);
		if (mData.length() > 0)
		    mData += ",";
		mData += "[\"" + key + "\"," + "\"" + value + "\"," + "\""
			+ iCountry_id + "\"]";
	    }
	    result += mData;
	    return (result + "]").trim();
	}

	private static void checkDataExists() {
	    if (mapData != null && countrySubregionData != null)
		return;
	    mapData = new TreeMap<Integer, TreeMap<String, String>>();
	    countrySubregionData = new TreeMap<Integer, TreeMap<String, TreeMap<String, String>>>();

	    TreeMap<String, String> localData = new TreeMap<String, String>();

	    localData
		    .put("Abkhazeti",
			    "4453727.39233571;5222749.7347448;4692011.90651965;5401644.79770205");
	    localData
		    .put("Ajara",
			    "4624997.95136708;5076294.49154824;4742369.90142692;5147436.55825007");
	    localData
		    .put("Guria",
			    "4642952.31477671;5129035.03642651;4749836.9213819;5186387.74798245");
	    localData
		    .put("Imereti",
			    "4699267.193085;5132334.64025327;4861785.29741904;5246003.72103646");
	    localData
		    .put("Kakheti",
			    "5014410.79279906;5020264.85199965;5202438.90492406;5247255.69462936");
	    localData
		    .put("Mtskheta-Mtianeti",
			    "4923141.01966964;5115099.56690955;5043947.59481159;5276534.32178235");
	    localData
		    .put("Qvemo Kartli",
			    "4861411.96975222;5036792.85264505;5044531.4000028;5139984.26064662");
	    localData
		    .put("Racha-Lechkumi-Qvemo Svaneti",
			    "4714981.03754959;5216014.9688403;4875322.42800479;5307115.08184612");
	    localData
		    .put("Samegrelo-Zemo Svaneti",
			    "4625233.13319981;5171272.15404462;4803377.71060359;5351178.78647015");
	    localData
		    .put("Samtskhe-Javakheti",
			    "4729820.14347887;5028593.68904512;4894136.98664508;5153434.64935598");
	    localData
		    .put("Shida Kartli",
			    "4834989.31664597;5121578.26863815;4961886.21717929;5197411.79589462");
	    localData
		    .put("South Ossetia",
			    "4851076.87211436;5164298.40600596;4967527.4483385;5273561.17737181");
	    localData
		    .put("Tbilisi",
			    "4964479.74593068;5104406.67040182;5011326.66984784;5137544.80841591");

	    mapData.put(1, localData);

	    localData = new TreeMap<String, String>();

	    localData
		    .put("Absheron",
			    "5428291.91785474;4817959.93779527;5635178.13063608;5009520.2982819");
	    localData
		    .put("Aran",
			    "5201942.34316987;4710043.24602735;5503747.92978227;5007735.07536018");
	    localData
		    .put("Daglig-Shirvan",
			    "5313555.69190192;4904463.99720735;5483944.44417736;5021658.26683252");
	    localData
		    .put("Ganja-Qazakh",
			    "5006234.68274827;4903214.16928034;5227964.4801223;5082377.42952276");
	    localData
		    .put("Kalbajar-Lachin",
			    "5076045.87406038;4702828.24493469;5217813.64282012;4911746.30814581");
	    localData
		    .put("Lankaran",
			    "5344626.12406625;4635186.82134015;5445893.13716698;4782232.39994163");
	    localData
		    .put("Nakhchivan",
			    "4982914.61055814;4699299.97324069;5137451.89096571;4836033.66855591");
	    localData
		    .put("Quba-Khachmaz",
			    "5321659.25046866;4990985.45788735;5496380.38923971;5137404.71011275");
	    localData
		    .put("Shaki-Zaqatala",
			    "5140549.89249546;4959306.33055605;5346799.42934779;5148033.98682595");
	    localData
		    .put("Yukhari-Karabakh",
			    "5169019.21643395;4741852.9832146;5303316.10256415;4935944.44017839");

	    mapData.put(2, localData);
	    localData = new TreeMap<String, String>();
	    localData
		    .put("Aragatsotn",
			    "4852404.88553197;4894151.2747059;4964274.21284589;4977948.15367246");
	    localData
		    .put("Ararat",
			    "4933248.74720444;4824401.64972492;5022616.66895529;4893852.67473987");
	    localData
		    .put("Armavir",
			    "4859047.64454724;4868938.76916234;4946579.8907911;4907368.80991677");
	    localData
		    .put("Gegharkunik",
			    "4988243.85954404;4846097.45028649;5118384.88042696;4974103.17615709");
	    localData
		    .put("Kotayk",
			    "4942543.42383124;4879929.19079844;5013662.55217752;4970994.64838682");
	    localData
		    .put("Lori",
			    "4900339.19913647;4963820.3748065;5004549.93866083;5048937.86137914");
	    localData
		    .put("Shirak",
			    "4836641.36819752;4930215.38734838;4919862.63413571;5040400.44698913");
	    localData
		    .put("Syunik",
			    "5086359.93478004;4698891.20654096;5191180.79042891;4845794.98613774");
	    localData
		    .put("Tavush",
			    "4983483.94950944;4960733.57791763;5076919.48315081;5056698.08657392");
	    localData
		    .put("Vayots Dzor",
			    "5016711.63686621;4792300.05239152;5100140.55898101;4867712.83782725");
	    localData
		    .put("Yerevan",
			    "4943871.6433586;4878121.53025405;4972308.25186048;4904148.57996272");

	    mapData.put(3, localData);
	    putSubregionData(1, "Abkhazeti", "Gagra",
		    "4453727.39233571;5334217.46721718;4508184.66060923;5401644.79770205");
	    putSubregionData(1, "Abkhazeti", "Gali",
		    "4618589.21583427;5222749.7347448;4669763.18169295;5287183.88417626");
	    putSubregionData(1, "Abkhazeti", "Gudauta",
		    "4492961.45231702;5322505.52205951;4553288.60018812;5398171.86021458");
	    putSubregionData(1, "Abkhazeti", "Gulripshi",
		    "4571329.16495643;5281677.68661722;4689901.32309436;5368552.54790097");
	    putSubregionData(1, "Abkhazeti", "Ochamchire",
		    "4580411.93170634;5258561.08809871;4692011.90651965;5344196.17078042");
	    putSubregionData(1, "Abkhazeti", "Sokhumi",
		    "4528484.8800669;5307545.20870616;4597669.70711844;5389391.98850475");
	    putSubregionData(1, "Ajara", "Keda",
		    "4647856.34920668;5085582.23614278;4689438.30728822;5116613.48376936");
	    putSubregionData(1, "Ajara", "Khelvachauri",
		    "4624997.95136708;5076294.49154824;4669089.46256146;5116106.61176312");
	    putSubregionData(1, "Ajara", "Khulo",
		    "4703601.72839033;5079982.04813528;4742369.90142692;5137554.23475106");
	    putSubregionData(1, "Ajara", "KobuleTi",
		    "4643411.76718044;5103079.22201861;4699527.32702333;5147436.55825007");
	    putSubregionData(1, "Ajara", "Shuakhevi",
		    "4686228.31785557;5076870.29564694;4733789.00140624;5132570.30136496");
	    putSubregionData(1, "Guria", "Chokhatauri",
		    "4689540.74783107;5130327.88087342;4749836.9213819;5173760.77307816");
	    putSubregionData(1, "Guria", "Lanchkhuti",
		    "4642952.31477671;5157597.6934892;4700507.59079161;5186387.74798245");
	    putSubregionData(1, "Guria", "Ozurgeti",
		    "4648481.29213158;5129035.03642651;4707904.9133833;5165734.36095311");
	    putSubregionData(1, "Imereti", "Bagdati",
		    "4747910.15186968;5132334.64025327;4800662.10760373;5190744.651544");
	    putSubregionData(1, "Imereti", "Chiatura",
		    "4798811.43926463;5179583.73857695;4837227.57378593;5226987.90358953");
	    putSubregionData(1, "Imereti", "Kharagauli",
		    "4786446.8373171;5135965.38533345;4842539.73183991;5185091.75949266");
	    putSubregionData(1, "Imereti", "Khoni",
		    "4711946.83578984;5195646.54846093;4746701.50079112;5246003.72103646");
	    putSubregionData(1, "Imereti", "Sachkhere",
		    "4815731.22723578;5174164.05001919;4861785.29741904;5230330.87749096");
	    putSubregionData(1, "Imereti", "Samtredia",
		    "4699267.193085;5160494.87970224;4735433.46765812;5202553.57567444");
	    putSubregionData(1, "Imereti", "Terjola",
		    "4755273.74321214;5183530.85634719;4801696.73749987;5206530.02822338");
	    putSubregionData(1, "Imereti", "Tkibuli",
		    "4757707.36741813;5200447.3990852;4802048.99614985;5234261.10537621");
	    putSubregionData(1, "Imereti", "Tskaltubo",
		    "4725713.1534042;5176517.48294303;4774210.74182516;5237868.72667367");
	    putSubregionData(1, "Imereti", "Vani",
		    "4719313.2239947;5133537.90656162;4765029.46411641;5181627.12020701");
	    putSubregionData(1, "Imereti", "Zestafoni",
		    "4760746.54110508;5165527.9725164;4812337.95032385;5196079.41454538");
	    putSubregionData(1, "Kakheti", "Akhmeta",
		    "5014618.18811814;5142624.25430544;5096406.65638789;5247255.69462936");
	    putSubregionData(1, "Kakheti", "Dedoflis Tskaro",
		    "5093635.34228599;5020264.85199965;5202438.90492406;5098422.77807768");
	    putSubregionData(1, "Kakheti", "Gurjaani",
		    "5066219.80398849;5091822.93133656;5118738.65043253;5146848.75613852");
	    putSubregionData(1, "Kakheti", "Kvareli",
		    "5071497.44814518;5131361.96077857;5134044.25047779;5180790.60539415");
	    putSubregionData(1, "Kakheti", "Lagodekhi",
		    "5110434.82426264;5105165.22312529;5168122.24738875;5163290.52777534");
	    putSubregionData(1, "Kakheti", "Sagarejo",
		    "5014410.79279906;5074077.31648458;5081038.73199823;5149774.17815159");
	    putSubregionData(1, "Kakheti", "Signagi",
		    "5069036.7764297;5049761.74034892;5163489.05000415;5116722.38062791");
	    putSubregionData(1, "Kakheti", "Telavi",
		    "5040207.21914491;5131120.68706314;5092714.57206286;5205401.60090738");
	    putSubregionData(1, "Mtskheta-Mtianeti", "Dusheti",
		    "4949870.24744518;5151226.58764021;5043947.59481159;5274095.96374194");
	    putSubregionData(1, "Mtskheta-Mtianeti", "Kazbegi",
		    "4923141.01966964;5225859.56650777;4993031.37199205;5276534.32178235");
	    putSubregionData(1, "Mtskheta-Mtianeti", "Mtskheta",
		    "4950334.10277063;5115099.56690955;5016423.14311407;5160812.73223353");
	    putSubregionData(1, "Mtskheta-Mtianeti", "Tianeti",
		    "4992548.56635563;5145090.49378065;5036878.89218286;5219188.7757816");
	    putSubregionData(1, "Qvemo Kartli", "Bolnisi",
		    "4925753.72774003;5039153.15119002;4985830.35606219;5087628.93471727");
	    putSubregionData(1, "Qvemo Kartli", "Dmanisi",
		    "4886054.96012562;5036792.85264505;4946642.15531827;5094874.69660704");
	    putSubregionData(1, "Qvemo Kartli", "Gardabani",
		    "4977770.04781395;5062635.4774525;5044531.4000028;5139984.26064662");
	    putSubregionData(1, "Qvemo Kartli", "Marneuli",
		    "4955830.39916837;5040524.32477591;5019893.80709745;5095104.81769933");
	    putSubregionData(1, "Qvemo Kartli", "Tetri Tskaro",
		    "4919690.4290102;5079244.33963142;4990597.02164396;5127480.07654626");
	    putSubregionData(1, "Qvemo Kartli", "Tsalka",
		    "4861411.96975222;5083495.15007366;4926027.3472691;5125507.76424419");
	    putSubregionData(1, "Racha-Lechkumi-Qvemo Svaneti", "Ambroloauri",
		    "4768723.78227157;5216014.9688403;4826975.76808225;5286314.9675361");
	    putSubregionData(1, "Racha-Lechkumi-Qvemo Svaneti", "Cageri",
		    "4734256.00913731;5230592.47778963;4798715.54583878;5277223.02984796");
	    putSubregionData(1, "Racha-Lechkumi-Qvemo Svaneti", "Lentekhi",
		    "4714981.03754959;5260680.50120786;4823945.35853761;5307115.08184612");
	    putSubregionData(1, "Racha-Lechkumi-Qvemo Svaneti", "Oni",
		    "4813010.53546808;5226484.81682547;4875322.42800479;5296530.71979866");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Abasha",
		    "4678788.77638936;5177132.3415623;4717387.35585147;5212107.51818901");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Chkhorotsku",
		    "4676687.72152707;5221206.42595048;4722611.33226862;5287918.75565677");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Khobi",
		    "4632166.54024679;5181343.04150993;4682718.30760307;5231601.85514554");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Martvili",
		    "4694766.20027217;5205232.72229473;4744132.6326916;5279102.83653195");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Mestia",
		    "4660508.69623891;5283166.87102683;4803377.71060359;5351178.78647015");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Poti",
		    "4634643.26212945;5171272.15404462;4649519.58813303;5191982.6521045");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Senaki",
		    "4660785.66844634;5182499.63368845;4705460.97296756;5229219.34806757");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Tsalendjikha",
		    "4663249.54005687;5237531.30481646;4703711.91720015;5291076.64071081");
	    putSubregionData(1, "Samegrelo-Zemo Svaneti", "Zugdidi",
		    "4625233.13319981;5208357.7449281;4679601.29296456;5256161.08731538");
	    putSubregionData(1, "Samtskhe-Javakheti", "Adigeni",
		    "4729820.14347887;5097960.27456617;4782740.75996;5137752.80155814");
	    putSubregionData(1, "Samtskhe-Javakheti", "Akhalkalaki",
		    "4800790.64210401;5037961.60275145;4867339.06665515;5113636.34242284");
	    putSubregionData(1, "Samtskhe-Javakheti", "Akhaltsikhe",
		    "4764212.70920441;5075841.85798812;4817522.79387422;5137072.02654675");
	    putSubregionData(1, "Samtskhe-Javakheti", "Aspindza",
		    "4783080.19087179;5057407.35260891;4836023.80478677;5116558.93028258");
	    putSubregionData(1, "Samtskhe-Javakheti", "Borjomi",
		    "4800948.4632927;5100276.47288273;4886374.27764266;5153434.64935598");
	    putSubregionData(1, "Samtskhe-Javakheti", "Ninotsminda",
		    "4834676.49070714;5028593.68904512;4894136.98664508;5091652.58906221");
	    putSubregionData(1, "Shida Kartli", "Gori",
		    "4874334.26229809;5122045.25003796;4933079.3734988;5197411.79589462");
	    putSubregionData(1, "Shida Kartli", "Kareli",
		    "4860075.55109527;5130032.56819483;4904466.33724265;5186549.97181886");
	    putSubregionData(1, "Shida Kartli", "Kaspi",
		    "4912921.14916012;5121578.26863815;4961886.21717929;5169314.14175764");
	    putSubregionData(1, "Shida Kartli", "Khashuri",
		    "4834989.31664597;5137390.95990685;4872331.96839306;5191281.59952242");
	    putSubregionData(1, "South Ossetia", "Akhalgori",
		    "4927193.13036991;5164298.40600596;4967527.4483385;5240009.50867812");
	    putSubregionData(1, "South Ossetia", "Java",
		    "4851076.87211436;5208816.18418578;4936867.16332114;5273561.17737181");
	    putSubregionData(1, "South Ossetia", "Tskhinvali",
		    "4878775.32311651;5177416.56781731;4939961.06618606;5234293.49501388");
	    putSubregionData(1, "South Ossetia", "Znauri",
		    "4853343.46347043;5177101.86835025;4889820.37262983;5213665.80505397");
	    putSubregionData(1, "Tbilisi", "Tbilisi",
		    "4964479.74593068;5104406.67040182;5011326.66984784;5137544.80841591");
	    putSubregionData(2, "Absheron", "Absheron",
		    "5438020.65295259;4859115.6956019;5554142.51227903;4959028.76446306");
	    putSubregionData(2, "Absheron", "Baku city",
		    "5487149.70356715;4817959.93779527;5635178.13063608;4952743.53131967");
	    putSubregionData(2, "Absheron", "Khizi",
		    "5428291.91785474;4939690.69287372;5515371.65017105;5009520.2982819");
	    putSubregionData(2, "Absheron", "Sumqayit city",
		    "5507672.62093281;4944803.96203582;5533438.28509683;4962383.94836308");
	    putSubregionData(2, "Aran", "Agdash",
		    "5251270.55472646;4907854.24299715;5301187.33136322;4981248.3147054");
	    putSubregionData(2, "Aran", "Agjabadi",
		    "5238504.29700266;4823601.05371004;5314102.21658948;4902390.68262296");
	    putSubregionData(2, "Aran", "Ali Bayramli",
		    "5441411.05983001;4851831.57190965;5448782.9865501;4865159.58031754");
	    putSubregionData(2, "Aran", "Barda",
		    "5228598.90750849;4888125.21808404;5284337.637827;4945316.38563092");
	    putSubregionData(2, "Aran", "Beylagan",
		    "5280010.87728364;4801943.38313345;5332323.10559027;4883802.60750035");
	    putSubregionData(2, "Aran", "Bilasuvar",
		    "5336266.83152658;4764730.5076426;5430038.92860897;4825447.62485409");
	    putSubregionData(2, "Aran", "Goychay",
		    "5297170.14088792;4930055.17499868;5349074.28030826;4964514.95116562");
	    putSubregionData(2, "Aran", "Hajigabul",
		    "5392326.1727406;4838676.19487367;5494378.09856078;4916164.18798217");
	    putSubregionData(2, "Aran", "Imishli",
		    "5314566.35918156;4802547.23498658;5385573.81065658;4885244.37871148");
	    putSubregionData(2, "Aran", "Kurdamir",
		    "5326199.22561544;4862990.29627385;5395412.53004538;4943602.07926902");
	    putSubregionData(2, "Aran", "Lankaran",
		    "5437514.04532617;4710043.24602735;5479926.11798631;4760429.72276053");
	    putSubregionData(2, "Aran", "Mingachevir",
		    "5222755.29662511;4970842.35369531;5237433.32937225;4980939.8388053");
	    putSubregionData(2, "Aran", "Neftchala",
		    "5422519.64817447;4714942.56410372;5503747.92978227;4800510.48354105");
	    putSubregionData(2, "Aran", "Saatly",
		    "5367165.65093776;4810241.94088651;5422557.01747058;4865991.61598727");
	    putSubregionData(2, "Aran", "Sabirabad",
		    "5371127.63695456;4806849.01685658;5448892.12162755;4886135.87159107");
	    putSubregionData(2, "Aran", "Salyan",
		    "5425355.03736479;4770947.09540868;5494383.64822557;4854475.69960639");
	    putSubregionData(2, "Aran", "Ujar",
		    "5283642.48547789;4908196.05965867;5342514.28464;4944827.99011516");
	    putSubregionData(2, "Aran", "Yevlakh",
		    "5201942.34316987;4926538.47929116;5261276.16174426;5007735.07536018");
	    putSubregionData(2, "Aran", "Zardab",
		    "5278104.62279616;4877558.09736996;5337183.22663887;4922880.3077203");
	    putSubregionData(2, "Daglig-Shirvan", "Agsu",
		    "5352174.65107169;4906486.53858359;5415956.68011523;4981983.08739866");
	    putSubregionData(2, "Daglig-Shirvan", "Ismailli",
		    "5313555.69190192;4940759.1588511;5399195.73835196;5021658.26683252");
	    putSubregionData(2, "Daglig-Shirvan", "Qobustan",
		    "5416211.89473723;4907719.52380889;5483944.44417736;4977525.3813956");
	    putSubregionData(2, "Daglig-Shirvan", "Shamakhi",
		    "5386664.31227547;4904463.99720735;5433287.07767196;5004796.4140267");
	    putSubregionData(2, "Ganja-Qazakh", "Agstafa",
		    "5021894.57331003;5006286.4737144;5096318.68647057;5082377.42952276");
	    putSubregionData(2, "Ganja-Qazakh", "Dashkasan",
		    "5100502.33829456;4908582.0539729;5147100.47399539;4963765.25409663");
	    putSubregionData(2, "Ganja-Qazakh", "Gadabay",
		    "5050012.51689433;4912477.81988401;5111233.24777392;4986302.53762105");
	    putSubregionData(2, "Ganja-Qazakh", "Ganja city",
		    "5151323.19516727;4958623.0621581;5161932.23001705;4972356.33951886");
	    putSubregionData(2, "Ganja-Qazakh", "Goranboy",
		    "5155911.54005174;4903214.16928034;5227964.4801223;5007325.0939391");
	    putSubregionData(2, "Ganja-Qazakh", "Khanlar",
		    "5129489.38270033;4906157.58296808;5177909.69220492;4987720.70361452");
	    putSubregionData(2, "Ganja-Qazakh", "Qazakh",
		    "5006234.68274827;5009124.72952009;5054598.08095466;5065231.72975114");
	    putSubregionData(2, "Ganja-Qazakh", "Samukh",
		    "5131725.44755484;4964417.52652551;5205281.79205098;5042652.63529318");
	    putSubregionData(2, "Ganja-Qazakh", "Shamkir",
		    "5089314.92986482;4947243.94091807;5155967.59386129;5032519.59002972");
	    putSubregionData(2, "Ganja-Qazakh", "Tovuz",
		    "5059636.10174224;4952659.21826774;5143480.33135961;5047462.88718273");
	    putSubregionData(2, "Kalbajar-Lachin", "Kalbajar",
		    "5076045.87406038;4837684.31913579;5205472.03531476;4911746.30814581");
	    putSubregionData(2, "Kalbajar-Lachin", "Lankaran",
		    "5109327.36620104;4784641.52890783;5202585.68818786;4859861.90835815");
	    putSubregionData(2, "Kalbajar-Lachin", "Qubadli",
		    "5163152.49954625;4738182.61825601;5212305.08093185;4791406.3435955");
	    putSubregionData(2, "Kalbajar-Lachin", "Zangilan",
		    "5168724.5101958;4702828.24493469;5217813.64282012;4754381.33587541");
	    putSubregionData(2, "Lankaran", "Jalilabad",
		    "5357926.21535493;4719628.70420863;5428358.16330073;4782232.39994163");
	    putSubregionData(2, "Lankaran", "Lankaran",
		    "5404365.09737506;4635186.82134015;5443310.53491208;4707071.291026");
	    putSubregionData(2, "Lankaran", "Lerik",
		    "5370932.6277307;4649548.45085059;5424938.88016031;4713061.42266523");
	    putSubregionData(2, "Lankaran", "Masally",
		    "5396219.79006795;4696821.76130744;5445893.13716698;4743851.10365854");
	    putSubregionData(2, "Lankaran", "Yardymli",
		    "5344626.12406625;4681716.28835673;5404296.63598229;4726173.45587893");
	    putSubregionData(2, "Nakhchivan", "Babek",
		    "5021404.60858992;4716794.94456938;5072235.0758766;4809981.38216123");
	    putSubregionData(2, "Nakhchivan", "Julfa",
		    "5061431.97589688;4711276.08650207;5113296.40396193;4775646.17617046");
	    putSubregionData(2, "Nakhchivan", "Nakhichevan",
		    "5044006.45665651;4747016.85359585;5068503.67492075;4756857.28111343");
	    putSubregionData(2, "Nakhchivan", "Ordubad",
		    "5089245.71191846;4699299.97324069;5137451.89096571;4767399.19595806");
	    putSubregionData(2, "Nakhchivan", "Sadarak",
		    "4982914.61055814;4810517.28949035;5004611.23700243;4829483.60891198");
	    putSubregionData(2, "Nakhchivan", "Shakhbuz",
		    "5049052.57453789;4762474.27309706;5102925.34746361;4808391.76205986");
	    putSubregionData(2, "Nakhchivan", "Sharur",
		    "4988669.53411177;4764257.49052479;5041733.73319428;4836033.66855591");
	    putSubregionData(2, "Quba-Khachmaz", "Davachi",
		    "5414374.85815575;4990985.45788735;5473129.07594266;5066720.86756145");
	    putSubregionData(2, "Quba-Khachmaz", "Khachmaz",
		    "5397818.82683047;5063421.48332466;5464022.81422399;5137404.71011275");
	    putSubregionData(2, "Quba-Khachmaz", "Quba",
		    "5333825.51784163;4996875.55797607;5427088.88394833;5083920.59757477");
	    putSubregionData(2, "Quba-Khachmaz", "Qusar",
		    "5321659.25046866;5035630.21735904;5407730.35720667;5119834.89022175");
	    putSubregionData(2, "Quba-Khachmaz", "Siazan",
		    "5434891.40595966;4993387.0072289;5496380.38923971;5039883.28673102");
	    putSubregionData(2, "Shaki-Zaqatala", "Balakan",
		    "5140549.89249546;5093926.07985833;5200298.15321199;5148033.98682595");
	    putSubregionData(2, "Shaki-Zaqatala", "Oguz",
		    "5262085.96961688;4982237.1856786;5309988.630543;5053012.27825502");
	    putSubregionData(2, "Shaki-Zaqatala", "Qabala",
		    "5290522.66728958;4959306.33055605;5346799.42934779;5045805.65605619");
	    putSubregionData(2, "Shaki-Zaqatala", "Qakh",
		    "5190188.35599446;4999216.18769623;5251743.35126432;5100498.68366396");
	    putSubregionData(2, "Shaki-Zaqatala", "Shaki",
		    "5209613.22358105;4975825.60721704;5295908.92990079;5084876.02604249");
	    putSubregionData(2, "Shaki-Zaqatala", "Zaqatala",
		    "5153843.88922601;5067854.88733692;5235562.70240611;5140340.30960044");
	    putSubregionData(2, "Yukhari-Karabakh", "Agdam",
		    "5198386.32273374;4836236.88482083;5263917.91031961;4898231.45530139");
	    putSubregionData(2, "Yukhari-Karabakh", "Fizuli",
		    "5233853.1039221;4772950.69525917;5303316.10256415;4827992.53346159");
	    putSubregionData(2, "Yukhari-Karabakh", "Jabrayil",
		    "5199008.01058928;4741852.9832146;5262127.50544779;4790456.71724299");
	    putSubregionData(2, "Yukhari-Karabakh", "Khojali",
		    "5169019.21643395;4811667.57690598;5223526.46130366;4868581.29558719");
	    putSubregionData(2, "Yukhari-Karabakh", "Khojavend",
		    "5192018.69365762;4775406.74073531;5270420.15356952;4848972.32073369");
	    putSubregionData(2, "Yukhari-Karabakh", "Shusha",
		    "5179305.09253479;4804900.09388961;5208567.73485305;4834137.99720887");
	    putSubregionData(2, "Yukhari-Karabakh", "Tartar",
		    "5176554.20887191;4870737.38275876;5241622.07846981;4935944.44017839");
	    putSubregionData(3, "Aragatsotn", "Aragatsotn",
		    "4852404.88553197;4894151.2747059;4964274.21284589;4977948.15367246");
	    putSubregionData(3, "Ararat", "Ararat",
		    "4933248.74720444;4824401.64972492;5022616.66895529;4893852.67473987");
	    putSubregionData(3, "Armavir", "Armavir",
		    "4859047.64454724;4868938.76916234;4946579.8907911;4907368.80991677");
	    putSubregionData(3, "Gegharkunik", "Gegharkunik",
		    "4988243.85954404;4846097.45028649;5118384.88042696;4974103.17615709");
	    putSubregionData(3, "Kotayk", "Kotayk",
		    "4942543.42383124;4879929.19079844;5013662.55217752;4970994.64838682");
	    putSubregionData(3, "Lori", "Lori",
		    "4900339.19913647;4963820.3748065;5004549.93866083;5048937.86137914");
	    putSubregionData(3, "Shirak", "Shirak",
		    "4836641.36819752;4930215.38734838;4919862.63413571;5040400.44698913");
	    putSubregionData(3, "Syunik", "Syunik",
		    "5086359.93478004;4698891.20654096;5191180.79042891;4845794.98613774");
	    putSubregionData(3, "Tavush", "Tavush",
		    "4983483.94950944;4960733.57791763;5076919.48315081;5056698.08657392");
	    putSubregionData(3, "Vayots Dzor", "Vayots Dzor",
		    "5016711.63686621;4792300.05239152;5100140.55898101;4867712.83782725");
	    putSubregionData(3, "Yerevan", "Yerevan",
		    "4943871.6433586;4878121.53025405;4972308.25186048;4904148.57996272");

	    // =localData.put("""&E1&""""&","""&A1&";&B1&";&C1&";&D1&""""&");

	    // select
	    // state_eng_id,state_eng,region_eng,distr_eng,ST_XMin(the_geom),ST_YMin
	    // (the_geom),ST_XMax(the_geom),ST_YMax(the_geom) from ( select case
	    // when state_eng='Georgia' then 1 when state_eng='Azerbaijan' then 2
	    // when state_eng='Armenia' then 3 end state_eng_id,
	    // state_eng,region_eng,distr_eng,ST_TRANSFORM(the_geom,900913) the_geom
	    // from subregions ) k

	    // select
	    // state_eng_id,region_eng,'localData.put("'||region_eng||'","'||ST_XMin(the_geom)||';'||ST_YMin(the_geom)||';'||ST_XMax(the_geom)||';'||ST_YMax(the_geom)||'");'
	    // from (select case
	    // when state_eng='Georgia' then 1
	    // when state_eng='Azerbaijan' then 2
	    // when state_eng='Armenia' then 3
	    // end state_eng_id,region_eng,ST_Union(st_transform(the_geom,900913))
	    // the_geom from districts
	    // group by state_eng,region_eng) b
	    // order by 1 ,2

	    // select
	    // state_eng_id,region_eng,distr_eng,'putSubregionData('||state_eng_id||',"'||region_eng||'","'||''||distr_eng||'","'||ST_XMin(the_geom)||';'||ST_YMin(the_geom)||';'||ST_XMax(the_geom)||';'||ST_YMax(the_geom)||'");'
	    // from (select case
	    // when state_eng='Georgia' then 1
	    // when state_eng='Azerbaijan' then 2
	    // when state_eng='Armenia' then 3
	    // end
	    // state_eng_id,region_eng,distr_eng,ST_Union(st_transform(the_geom,900913))
	    // the_geom from districts
	    // group by state_eng,region_eng,distr_eng) b
	    // order by 1 ,2, 3

	}

	private static TreeMap<String, String> getSubregions(int country_id,
		String region) {
	    TreeMap<String, TreeMap<String, String>> regions = countrySubregionData
		    .get(country_id);
	    if (regions == null)
		return null;
	    return regions.get(region);
	}

	private static void putSubregionData(int country_id, String region,
		String sub_region, String data) {
	    TreeMap<String, TreeMap<String, String>> regions = countrySubregionData
		    .get(country_id);
	    if (regions == null) {
		regions = new TreeMap<String, TreeMap<String, String>>();
		countrySubregionData.put(country_id, regions);
	    }
	    TreeMap<String, String> sub_regions = regions.get(region);
	    if (sub_regions == null) {
		sub_regions = new TreeMap<String, String>();
		regions.put(region, sub_regions);
	    }
	    sub_regions.put(sub_region, data);
	}
    }%>
<%
    String data = DataCollector.getData(
	    request.getParameter("country_id"),
	    request.getParameter("region"));
    response.setContentType("application/json");
    out.print(data);
%>
